Source for file Thumbnail.php
Documentation is available at Thumbnail.php
* FCKeditor - The text editor for internet
* Copyright (C) 2003-2005 Frederico Caldeira Knabben
* Licensed under the terms of the GNU Lesser General Public License:
* http://www.opensource.org/licenses/lgpl-license.php
* For further information visit:
* http://www.fckeditor.net/
* File Name: Thumbnail.php
* Implements the Thumbnail command, to return
* a thumbnail to the browser for the sent file,
* if the file is an image an attempt is made to
* generate a thumbnail, otherwise an appropriate
* Grant French (grant@mcpuk.net)
include "helpers/iconlookup.php";
function Thumbnail($fckphp_config,$type,$cwd) {
//$mimeIcon=getMimeIcon($mime);
$fullfile=
$this->real_cwd.
'/'.
$this->filename;
$thumbfile=
$this->real_cwd.
'/.thumb_'.
$this->filename;
//Try and find a thumbnail, else try to generate one
// else send generic picture icon.
if ($this->isJPEG($mime,$ext)) {
} elseif ($this->isGIF($mime,$ext)) {
} elseif ($this->isPNG($mime,$ext)) {
imagejpeg($result,$thumbfile,70);
imagepng($result,$thumbfile);
imagegif($result,$thumbfile);
if ($iconMime==
false) $iconMime=
"image/jpeg";
header("Content-type: $iconMime",true);
//If mime magic is installed
$mime=
mime_content_type($file);
if ($start4==
"\x89PNG") {
} elseif ($start3==
"GIF") {
} elseif ($start3==
"\xFF\xD8\xFF") {
} elseif ($start4==
"hsi1") {
unset
($start3);unset
($start4);
if (($mime==
"image/jpeg")||
($mime==
"image/jpg")||
($mime==
"image/pjpeg")||
($ext==
"jpg")||
($ext==
"jpeg")) {
function isGIF($mime,$ext) {
if (($mime==
"image/gif")||
($ext==
"gif")) {
function isPNG($mime,$ext) {
if (($mime==
"image/png")||
($ext==
"png")) {
$img=
@imagecreatefromjpeg($this->real_cwd.
'/'.
$this->filename);
$img=
@imagecreatefromgif($this->real_cwd.
'/'.
$this->filename);
$img=
@imagecreatefrompng($this->real_cwd.
'/'.
$this->filename);
$width=
imagesx($img); $height=
imagesy($img);
if ($width>
$height) { $n_height=
$height*
(96/
$width); $n_width=
96; } else { $n_width=
$width*
(96/
$height); $n_height=
96; }
if ($n_width<
96) $x=
round((96-
$n_width)/
2);
if ($n_height<
96) $y=
round((96-
$n_height)/
2);
$thumb=
imagecreatetruecolor(96,96);
#Background colour fix by:
#Ben Lancaster (benlanc@ster.me.uk)
$bgcolor =
imagecolorallocate($thumb,255,255,255);
imagefill($thumb, 0, 0, $bgcolor);
if (!($result=
@imagecopyresampled($thumb,$img,$x,$y,0,0,$n_width,$n_height,$width,$height))) {
$result=
imagecopyresized($thumb,$img,$x,$y,0,0,$n_width,$n_height,$width,$height);
$result=
imagecopyresized($thumb,$img,$x,$y,0,0,$n_width,$n_height,$width,$height);
return ($result)?
$thumb:
false;
Documentation generated on Mon, 05 May 2008 16:23:11 +0400 by phpDocumentor 1.4.0